import { gameConfigHandle } from "core/config/gameConfig"
import { ItemModel } from "core/model/itemModel"
import { PlayerModel } from "core/model/playerModel"
import utils from "core/utils/utils"
import playerHandle from "./playerHandle"

class GemHandle {
    //计算当前宝石可升级共鸣等级
    getGemTeamLvlMax(player: PlayerModel) {
        let types = gameConfigHandle.gameConfig.equipment.equipmentListType
        let lvl = gameConfigHandle.gameConfig.gem.gemTeamLvlMax
        let partner = playerHandle.getPartner(player)
        for (let i = 0; i < types.length; i++) {
            let gems: ItemModel[] = partner.equipmentsGem[types[i]]
            for (let j = 0; j < 4; j++) {
                if (!gems[j]) {
                    lvl = 0
                    break
                } else {
                    let gemLvl = gameConfigHandle.configByID[gems[j].tid].gemLvl
                    if (lvl > gemLvl) {
                        lvl = gemLvl
                    }
                }
            }
            if (lvl == 0) {
                break
            }
        }
        return lvl
    }
}

let gemHandle = new GemHandle()

export default gemHandle